package com.swjd.service.impl;

import com.swjd.dao.GoodsMapper;
import com.swjd.pojo.Goods;
import com.swjd.service.GoodsService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by hxl on 2019/5/31  8:53
 */
@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private GoodsMapper goodsMapper;

    //根据用户输入的内容进行模糊查询
    @Override
    public List<Goods> fuzzyQuery(@Param("input") String input) {
        return goodsMapper.fuzzyQuery(input);
    }

    @Override
    public List<Goods> selectUserByGoods(String username) {//用户查询发布的商品信息
        return goodsMapper.selectUserByGoods(username);
    }

    //查询商品是否已经售出
    @Override
    public List<Goods> selectIfSell() {
        return goodsMapper.selectIfSell();
    }

    ////添加商品信息
    @Override
    public int insertGoods(Goods goods) {
        return goodsMapper.insertGoods(goods);
    }

    ////删除商品信息
    @Override
    public int deleteByID(Integer goodsID) {
        return goodsMapper.deleteByID(goodsID);
    }

    //修改商品信息
    @Override
    public int updateByID(Goods goods) {
        return goodsMapper.updateByID(goods);
    }

    //修改商品状态
    @Override
    public int updateByStatus() {
        return goodsMapper.updateByStatus();
    }
}
